#ifndef SIGNALCLIENT_H
#define SIGNALCLIENT_H
#include <QtCore/QObject>
#include <QtWebSockets/QWebSocket>
#include <QObject>
#include <QJsonObject>
#include <QJsonDocument>
#include <QTimer>

class SignalClient : public QObject
{
Q_OBJECT
public:
    explicit SignalClient(const QUrl &url, bool debug = false,
                          QObject *parent = Q_NULLPTR);
    ~SignalClient();

Q_SIGNALS:
    void closed();
    void connected();
    void response(int type,QJsonObject);
public:
    void SendLogin();
    void SendInRoom(QString );
    void SendListRoom(QString);
    bool Connected();
    void SetURL(QString);
    void SendSDPOffer(QString peer,QString sdp);
    void SendICECandidate(QString peer,QString sdp);

    QString PeerName();
private Q_SLOTS:
    void onConnected();
    void onUnConnected();
    void onTextMessageReceived(QString message);
    void onSocketError(QAbstractSocket::SocketError error);
    void onReconenectTimeout();
private:
    QString m_room_name;  // 所属房间名称
    QString m_peer_name;  // 节点名称

    QWebSocket m_webSocket;
    QUrl m_url;
    bool m_debug;
    bool m_connected;
    QTimer m_timer;
};


#endif // SIGNALCLIENT_H
